<?php
class tree_chk
{

    public function __construct ()
    {
        $this->db = new DB();
        $this->reg = array();
        $this->save = array();
        $this->once = 1;
    }

    public function acct_Recursive ($account)
    {
        if (!isset($account))
        {
            echo "<script>alert('无此帐号!');location.href='#'</script>";
            exit();
        }
        if ($this->once == 1)
        {
            array_push($this->save, $account);
            $this->once = 0;
        }
        $qry = $this->db->query("SELECT `id`,`account`,`prev_id`,`acl` FROM `k_user` WHERE `account`='" . $account . "' LIMIT 1");
        $rlt = mysql_fetch_array($qry);
        if ($rlt['acl'] == "255")
        {
            exit();
        }
        if (isset($rlt['id']))
        {
            $qry2 = $this->db->query("SELECT `id`,`account`,`prev_id`,`acl` FROM `k_user` WHERE `acl`>0 and `prev_id`='" . $rlt['id'] . "'");
            while ($rlt2 = mysql_fetch_array($qry2))
            {
                array_push($this->reg, $rlt2['account']);
                array_push($this->save, $rlt2['account']);
            }
        }
        if (0 < count($this->reg))
        {
            foreach ($this->reg as $val)
            {
                $first = array_shift($this->reg);
                $first = (string) $first;
                if (!empty($first))
                {
                    $this->acct_Recursive((string) $first);
                }
            }
        }
    }

    public function is_serach ($account)
    {
        if (in_array($account, $this->save))
        {
            return "1";
        }
        return "0";
    }

}

?>